<button class="btn btn-success btn-xs" data-toggle="modal" data-target="#contractedCustomerEdit{{ $id }}">编辑</button>

<div class="modal fade" id="contractedCustomerEdit{{ $id }}" tabindex="-1" role="dialog" aria-labelledby="exampleModal2" aria-hidden="true">
    <div class="modal-dialog modal-xs">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size: 36px;">&times;</button>
                <h4 class="modal-title" id="myModalLabel">编辑</h4>
            </div>
            <div class="modal-body">
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">合同编号</label>
                    <input type="text" name="contractNo{{ $id }}" value="{{ $data->contract_no }}" class="form-control" placeholder="请输入合同编号">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">男方姓名</label>
                    <input type="text" name="maleName{{ $id }}" value="{{ $data->male_name }}" class="form-control" placeholder="请输入男方姓名">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">男方血型</label>
                    <select name="maleBloodType{{ $id }}" class="form-control">
                        @foreach(__('contracted_customer.bloodTypeArr') as $key => $value)
                            @if($data->male_blood_type === $key)
                                <option value="{{ $key }}" selected>{{ $value }}</option>
                            @else
                                <option value="{{ $key }}">{{ $value }}</option>
                            @endif
                        @endforeach
                    </select>
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">手机号</label>
                    <input type="text" name="maleMobile{{ $id }}" value="{{ $data->male_mobile }}"  maxlength="11" class="form-control" placeholder="请输入手机号">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">女方姓名</label>
                    <input type="text" name="femaleName{{ $id }}" value="{{ $data->female_name }}" class="form-control" placeholder="请输入女方姓名">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">女方血型</label>
                    <select name="femaleBloodType{{ $id }}" class="form-control">
                        @foreach(__('contracted_customer.bloodTypeArr') as $k => $v)
                            @if($data->female_blood_type === $k)
                                <option value="{{ $k }}" selected>{{ $v }}</option>
                            @else
                                <option value="{{ $k }}">{{ $v }}</option>
                            @endif
                        @endforeach
                    </select>
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">手机号</label>
                    <input type="text" name="femaleMobile{{ $id }}" value="{{ $data->female_mobile }}" maxlength="11" class="form-control" placeholder="请输入手机号">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">地址</label>
                    <input type="text" name="contactAddress{{ $id }}" value="{{ $data->contact_address }}" class="form-control" placeholder="请输入地址">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">合同金额</label>
                    <div class="input-group">
                        <div class="input-group-addon">$</div>
                        <input type="number" name="contractAmount{{ $id }}" value="{{ $data->contract_amount }}" class="form-control" placeholder="请输入合同金额">
                    </div>
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">冷冻日期</label>
                    <input type="date" name="freezeDate{{ $id }}" value="{{ $data->freeze_date }}" formate="" class="form-control" placeholder="请输入冷冻日期">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">备注</label>
                    <textarea name="remark{{ $id }}" class="form-control" value="{{ $data->remark }}" placeholder="请输入备注"></textarea>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="contractedCustomerEdit({{ $id }})">提交</button>
            </div>
        </div>
    </div>
</div>
<script>
    function contractedCustomerEdit(id)
    {
        ajaxPostFunc('/admin/ajax/contractedCustomerEdit', {
            id:id,
            contract_no: $("input[name='contractNo"+id+"']").val(),
            male_name: $("input[name='maleName"+id+"']").val(),
            male_blood_type: $("select[name='maleBloodType"+id+"'] option:selected").val(),
            male_mobile: $("input[name='maleMobile"+id+"']").val(),
            female_name: $("input[name='femaleName"+id+"']").val(),
            female_blood_type: $("select[name='femaleBloodType"+id+"'] option:selected").val(),
            female_mobile: $("input[name='femaleMobile"+id+"']").val(),
            contact_address: $("input[name='contactAddress"+id+"']").val(),
            contract_amount: $("input[name='contractAmount"+id+"']").val(),
            freeze_date: $("input[name='freezeDate"+id+"']").val(),
            remark: $("textarea[name='remark"+id+"']").val(),
            _token: $.admin.token
        }, {}, res => {
            console.log(res);
            window.location.reload();
        });
    }
</script>
